package com.heima.wemedia.util;

import org.springframework.stereotype.Component;

@Component
public class WmThreadLocalUtil {


    private WmThreadLocalUtil() {
    }


    private final static ThreadLocal<String> WM_USER_THREAD_LOCAL = new ThreadLocal<>();


    //将userId写入
    public static void setUserId(String userId) {
        WM_USER_THREAD_LOCAL.set(userId);
    }

    //获得userId
    public static String getUserId() {
        return WM_USER_THREAD_LOCAL.get();
    }

    //移除userId
    public static void clear() {
        WM_USER_THREAD_LOCAL.remove();
    }
}
